﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>采摘入库管理</title>

</head>

<body>

    <div class="pd-5">
        <div class="row cl" id="findfdiv">
            <div class="formControls col-3"></div>
            <div class="formControls col-3">
                <input type="text" class="input-text" placeholder="输入农作物名称" id="findfv1" name="findfv1">
            </div>
            <div class="formControls col-3">
                <span class="select-box">
                    <select class="select" size="1" name="findinfofv4" id="findinfofv4">
                        <option value="待入库">待入库</option>
                        <option value="已入库">已入库</option>
                    </select></span>
            </div>
            <div class="formControls col-3">
                <button onclick="hcrainpage()" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 查询</button>
            </div>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-5">
            <span class="l">
                <!-- <a href="javascript:;" onclick="toolDelete()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>
                <a href="javascript:;" onclick="toolUpdate()" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6df;</i> 修改</a>-->
                <a href="javascript:;" onclick="savetotaskstre()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 提交</a></span>
            <span class="r">操作提示：入库量为空的将不作处理。如果对应采摘无效，将入库量填为0也可以噢<strong>^_^</strong> </span>

        </div>
        <div id="hcvueapp" class="mt-5 ml-20">
            <div class="panel panel-default" v-for="site in listinfo">
                <div class="panel-header">{{ site.fv1 }}--{{ site.fv2 }}</div>
                <div class="panel-body">
                    <table class="table table-border table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>任务信息</th>
                                <th>状态</th>
                                <th>采摘量</th>
                                <th>入库量</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="worklist in site.subinfo" v-bind:class="{ success: worklist.infofv4 == '待入库', 'warning': worklist.infotype === 1 }">
                                <td>编号：{{ worklist.taskno}}地块：{{ worklist.infofv1}}采摘时间：{{ worklist.infodataaddtime.Value}}</td>
                                <td>{{ worklist.taskstatus }}-{{ worklist.infofv4 }}</td>
                                <td>{{ worklist.infonv2 }}</td>

                                <td>
                                    <div v-if="worklist.infofv4 === '待入库'">
                                        <input type="text" class="input-text" placeholder="实际入库量" v-model="worklist.infonv3" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" />
                                    </div>
                                    <div v-else>
                                        <input type="text" class="input-text" placeholder="实际入库量" v-model="worklist.infonv3" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" />
                                    </div>
                                </td>

                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- <div v-html="message"></div>
    
            <button v-on:click="greet">Greet</button>-->
            <div class="mt-5 row">
                <div id="page1"></div>
            </div>

        </div>
    </div>

    <script type="text/javascript" src="../lib/layui/layui2.js"></script>
    <script type="text/javascript" src="../js/vue.min.js"></script>
    <script>
        var hcvueapp = new Vue({
            el: '#hcvueapp',
            data: {
                message: '<h1>菜鸟教程</h1>',
                listinfo: []
            },
            methods: {
                vueaddTaskListInfo: function (taskid, workinfotype, infoid, infoname, infomj) {
                    //生产任务ID  生产作业类型 （22清园33打地） 地ID  地编号  地面积
                    if (taskid != "" && taskid != null && taskid != 'undefined') {
                        if (workinfotype == "1111") {
                            toolAdd("添加采摘信息", "sctasklist-work-ae" + workinfotype + ".html?action=add&urltaskid=" + taskid + "&urlinfoid=" + infoid +
                                "&urlinfoname=" + infoname + "&urlinfomj=" + infomj + "&urlworkinfotype=" + workinfotype);
                        }
                        else {
                            toolAdd("添加作业信息", "sctasklist-work-ae.html?action=add&urltaskid=" + taskid + "&urlinfoid=" + infoid +
                                "&urlinfoname=" + infoname + "&urlinfomj=" + infomj + "&urlworkinfotype=" + workinfotype);
                        }
                    }
                    else {
                        layer.alert("请在编辑情况下操作", { icon: 1 });
                    }
                },
                vuetoolUpdateByIdCheckUrl: function (workinfoid, page, name) {
                    toolUpdateByIdCheckUrl(workinfoid, page, name);
                },
                vuetoolDelete: function (workinfoid, table, mkey) {
                    toolDelete(workinfoid, table, mkey);
                }
            }
        })
    </script>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="../lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_list.js"></script>

    <script type="text/javascript">
        var whereaddinfo = "";
        $(function () {
            spsetBaseNoBt("yw_baseinfo", "id", "yw_baseinfo as T", "*", "#tablelist", "sctaskintostore", "生产任务管理", "sctaskintostore");
            hcrainpage(1);
        });
        function savetotaskstre() {
            var needupdate = 0;
            var updatecount = 0;
            for (var sp in hcvueapp.listinfo) {
                var subinfo = hcvueapp.listinfo[sp].subinfo;
                for (var lindex in subinfo) {
                    console.log(subinfo[lindex].infonv3);
                    if (subinfo[lindex].infonv3 == null || subinfo[lindex].infonv3 == ""
                        || subinfo[lindex].infonv3 == " " || isNaN(subinfo[lindex].infonv3)) {
                        continue;
                    }
                    var addinfo = "inouttype%采摘入库"
                        + "$outstate%待出库"
                        + "$dkid%" + subinfo[lindex].infoid
                        + "$dkname%" + subinfo[lindex].infofv1
                        + "$taskid%" + subinfo[lindex].id
                        + "$taskno%" + subinfo[lindex].taskno
                        + "$tasklistid%" + subinfo[lindex].listid
                        + "$storehouseid%0$hasoutall%0"
                        + "$productid%" + hcvueapp.listinfo[sp].id
                        + "$productname%" + hcvueapp.listinfo[sp].fv1
                        + "$storeall%" + subinfo[lindex].infonv3;
                    hcui_ajaxasync = false;
                    //入库处理-这里要禁用异步，同一客户端并发服务时，异步反面会慢？
                    hcdoadd2017("hsc_task_store", addinfo, 1, "{'settype':1,'byfile_name':'tasklistid'}", function (info) {

                        //更新记录--已入库
                        if (info == "ok") {
                            updatecount++;
                            hcdoedit("hsc_task_info", "id", subinfo[lindex].listid,
                            "infofv4%已入库$infonv3%" + subinfo[lindex].infonv3, function (info2) { });
                        }

                    });
                    hcui_ajaxasync = true;
                }
            }
            layer.msg('完成入库操作，记录数：' + updatecount, { icon: 1 });
            //重新加载 
            if (updatecount > 0) {
                hcrainpage(1);
            }


        }
        function hcrainpage(curr) {
            var finddcno = $("#findfv1").val();
            var findinfofv4 = $("#findinfofv4").val();
            if (finddcno) {
                whereaddinfo = " and fv1 like '%" + finddcno + "%'";
            }
            else { whereaddinfo = ""; }
            $.ajax({
                type: "post",
                url: "../ashx/spui.ashx",
                data: {
                    "action": "getpageinfo",
                    "pagenow": curr || 1,
                    "pagesize": 50,
                    "select": "t.id,t.fv1,t.fv2",
                    "table": "yw_baseinfo as t",
                    "group": "",
                    "having": "",
                    "where": " type=1 and maintype=1 " + whereaddinfo,
                    "order": "",
                    "subinfo": "id,taskno,tasksctype,tasksctypename,taskstatus,listid,infoid,infofv1,infofv4,infonv1,infonv2,infonv3,infodataaddtime#view进行中的作业#tasksctype-@id,infofv4-" + findinfofv4 + ",databranchid-" + HCUser.HCUorg + "#id#"//子查询  当前机构 当前物品
                },
                async: true,
                cache: false,
                error: function (error) {

                },
                success: function (data) {
                    var result = JSON.parse(data);
                    hcvueapp.listinfo = result.data;
                    //显示分页
                    laypage({
                        cont: 'page1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                        pages: result.message || 0, //通过后台拿到的总页数
                        curr: curr || 1, //当前页
                        jump: function (obj, first) { //触发分页后的回调
                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                                hcrainpage(obj.curr);
                            }
                        }
                    });

                }
            });




        };

        //重新加载-重载
        function findreolad(isback) {
            hcrainpage(1);
        }
    </script>
</body>
</html>
